package it.marcomondini.proximitytools.facades;

import it.marcomondini.proximitytools.MyApplication;
import it.marcomondini.proximitytools.R;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.Color;

public class NotificationFacade {
	
	private NotificationManager notificationManager = (NotificationManager) MyApplication.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
	private static NotificationFacade instance = new NotificationFacade();

	private NotificationFacade(){
	}
	
	public static NotificationFacade instance(){
		return instance;
	}
	
	public void forward(Context ctx, int notificationID, PendingIntent pendingIntent, String message){
						
		Notification notification = notificationFactory();	
		notification.setLatestEventInfo(ctx, "Event detected", message, pendingIntent);

		notificationManager.notify(notificationID, notification);
	}
	
	public static Notification notificationFactory() {
		Notification notification = new Notification();
		
		notification.icon = R.drawable.ic_menu_notifications;
		notification.when = System.currentTimeMillis();
		
		notification.flags |= Notification.FLAG_AUTO_CANCEL |Notification.FLAG_SHOW_LIGHTS;
		
		notification.defaults |= Notification.DEFAULT_VIBRATE;
		
		notification.ledARGB = Color.RED;
		notification.ledOnMS = 1500;
		notification.ledOffMS = 1500;
		
		return notification;
	}

}
